﻿<UserControl x:Class="BadHabit.Factory.Controls.TeamMemberDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:BadHabit_Factory_Controls="clr-namespace:BadHabit.Factory.Controls"  
    xmlns:BadHabit_WPFTools="clr-namespace:BadHabit.WPFTools;assembly=BadHabit.WPFTools"        
    xmlns:Microsoft_Toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
    
    xmlns:props="clr-namespace:BadHabit.Factory.Properties"
    Loaded="UserControl_Loaded">
    
    <StackPanel Orientation="Vertical" DataContextChanged="UserControl_DataContextChanged">

        <!-- HEADER -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>


            <ContentControl Grid.Column="0"
                                    x:Name="teamMemberImageControl"
                                    Style="{StaticResource TeamMemberImageControl}" Width="50" Height="50" Margin="0,0,3,0" />

            <StackPanel Grid.Column="1" Orientation="Vertical" >
                <TextBlock Text="{Binding NickName}" FontSize="22" TextWrapping="Wrap"/>
                <TextBlock Grid.Column="1" Grid.Row="6" Foreground="Red" Text="{x:Static props:Resources.Account_inactive}" >                    
                            <TextBlock.Style>
                                <Style>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Disable}" Value="False">
                                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding Disable}" Value="{x:Null}">
                                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                </TextBlock>
                <TextBlock x:Name="changeImageTextBlock" TextWrapping="Wrap">
                <Hyperlink Click="Hyperlink_Click">
                    <TextBlock Text="{x:Static props:Resources.Change_image}" TextWrapping="Wrap">
                        <TextBlock.Style>
                                <Style>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ClientContactRole}" Value="True">
                                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style> 
                        </TextBlock>
                </Hyperlink>
                <TextBlock Text="{x:Static props:Resources.Create_your_avatar}" TextWrapping="Wrap">
                    <TextBlock.Style>
                                <Style>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ClientContactRole}" Value="True">
                                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style> 
                        </TextBlock>                
                <Hyperlink                   
                    RequestNavigate="Hyperlink_RequestNavigate"
                    NavigateUri="http://www.sp-studio.de/">
                    <TextBlock Padding="0,0,0,0" Text="{x:Static props:Resources.here}">
                        <TextBlock.Style>
                                <Style>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ClientContactRole}" Value="True">
                                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style> 
                        </TextBlock>
                </Hyperlink>
                        </TextBlock>

            </StackPanel>


        </Grid>

        <!-- AUTHETICATION -->
        <GroupBox Header="{x:Static props:Resources.Authentication}" x:Name="authenticationGroupBox">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <TextBlock Grid.Column="0" Grid.Row="1" >
                            <TextBlock.Style>
                                <Style TargetType="TextBlock" BasedOn="{StaticResource Label}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ElementName=useWindowsAuthenticationCheckBox,Path=IsChecked}" Value="True">
                                            <Setter Property="TextBlock.Text" Value="{x:Static props:Resources.Windows_account}"/>
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding ElementName=useWindowsAuthenticationCheckBox,Path=IsChecked}" Value="False">
                                            <Setter Property="TextBlock.Text" Value="{x:Static props:Resources.User_id}"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                </TextBlock>
                <TextBlock Grid.Column="0" Grid.Row="2" Text="{x:Static props:Resources.Access_key}">
                            <TextBlock.Style>
                                <Style TargetType="TextBlock" BasedOn="{StaticResource Label}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding AccessKey}" Value="{x:Null}">
                                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                        </DataTrigger>                                
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                </TextBlock>

                <CheckBox x:Name="useWindowsAuthenticationCheckBox" Grid.Column="1" Grid.Row="0" Click="useWindowsAuthenticationCheckBox_Click" Content="{x:Static props:Resources.Use_windows_authentication}">
                    <CheckBox.Style>
                        <Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding AccessKey}" Value="{x:Null}">
                                    <Setter Property="CheckBox.IsChecked" Value="True"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </CheckBox.Style>
                </CheckBox>
                <TextBox Grid.Column="1" Grid.Row="1" Style="{StaticResource FormTextBox}"
                         MaxLength="255"
                         Text="{Binding MemberId, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/>

                <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding AccessKey}" x:Name="accessKeyTextBlock">
                            <TextBox.Style>
                                <Style TargetType="TextBox" BasedOn="{StaticResource LabelInfo}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding AccessKey}" Value="{x:Null}">
                                            <Setter Property="TextBox.Visibility" Value="Collapsed"/>
                                        </DataTrigger>                                
                                    </Style.Triggers>
                                </Style>
                            </TextBox.Style>
                </TextBox>


                <Button Grid.Column="1" Grid.Row="3" Click="Button_Click" Content="{x:Static props:Resources.New_access_key}">
                    <Button.Style>
                        <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding AccessKey}" Value="{x:Null}">
                                    <Setter Property="Button.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                </Button>
            </Grid>

        </GroupBox>

        <!-- DETAILS -->
        <GroupBox Header="{x:Static props:Resources.Details}" x:Name="detailGroupBox">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"  />
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"  />
                    <RowDefinition Height="Auto"  />
                    <RowDefinition Height="Auto"  />
                    <RowDefinition Height="Auto"  />
                    <RowDefinition Height="Auto"  />
                    <RowDefinition Height="Auto"  />
                </Grid.RowDefinitions>
                <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Nick_name}"/>
                <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource Label}" VerticalAlignment="Top" Text="{x:Static props:Resources.E_mail}"/>

                <TextBlock Grid.Column="0" Grid.Row="2" x:Name="companyTextBlock" Text="{x:Static props:Resources.Company}">
                            <TextBlock.Style>
                                <Style BasedOn="{StaticResource Label}" TargetType="TextBlock">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ClientContactRole}" Value="False">
                                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                </TextBlock>

                <TextBlock Grid.Column="0" Grid.Row="3" x:Name="detailsTextBlock" VerticalAlignment="Top" Text="{x:Static props:Resources.Details}">
                            <TextBlock.Style>
                                <Style BasedOn="{StaticResource Label}" TargetType="TextBlock">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ClientContactRole}" Value="False">
                                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                </TextBlock>
                <TextBlock Grid.Column="0" Grid.Row="4"  Text="{x:Static props:Resources.Default_unit_name}">
                            <TextBlock.Style>
                                <Style BasedOn="{StaticResource Label}" TargetType="TextBlock">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ClientContactRole}" Value="True">
                                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                </TextBlock>

                <TextBox Grid.Column="1" Grid.Row="0" 
                         Text="{Binding NickName, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                         MaxLength="255">
                    <TextBox.Style>
                        <Style BasedOn="{StaticResource FormTextBox}" TargetType="TextBox">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding AccessKey}" Value="{x:Null}">
                                    <Setter Property="TextBox.IsEnabled" Value="False"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding ClientContactRole}" Value="True">
                                    <Setter Property="TextBox.IsEnabled" Value="True"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBox.Style>
                </TextBox>

                <TextBox Grid.Column="1" Grid.Row="1"
                         MaxLength="150"
                         TextWrapping="Wrap"
                         Text="{Binding EmailAccount, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}">
                    <TextBox.Style>
                        <Style BasedOn="{StaticResource FormTextBox}" TargetType="TextBox">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding AccessKey}" Value="{x:Null}">
                                    <Setter Property="TextBox.IsEnabled" Value="False"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding ClientContactRole}" Value="True">
                                    <Setter Property="TextBox.IsEnabled" Value="True"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBox.Style>
                </TextBox>


                <TextBox Grid.Column="1"  Grid.Row="2" Text="{Binding Company}" x:Name="companyTextBox">
                    <TextBox.Style>
                        <Style BasedOn="{StaticResource FormTextBox}" TargetType="TextBox">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ClientContactRole}" Value="False">
                                    <Setter Property="TextBox.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBox.Style>
                </TextBox>
                <TextBox Grid.Column="1"  Grid.Row="3" Text="{Binding ContactData}" x:Name="contactDataTextBox" Margin="2,2,2,0" VerticalAlignment="Top" MinHeight="50" AcceptsReturn="True" TextWrapping="Wrap"  >
                    <TextBox.Style>
                        <Style BasedOn="{StaticResource FormTextBox}" TargetType="TextBox">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ClientContactRole}" Value="False">
                                    <Setter Property="TextBox.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBox.Style>
                </TextBox>

                <!--<BadHabit_WPFTools:ComboBox 
                            Grid.Column="1" Grid.Row="4"                             
                            SelectedValuePath="UnitName"
                            SelectedValue="{Binding DefaultUnitName}"
                            ItemTemplate="{StaticResource BacklogItemUnitTemplate}"
                            SelectedItemTemplate="{StaticResource BacklogItemUnitTemplate}"
                            ItemsSource="{Binding Source={StaticResource GenericUnitList}}"
                            >-->
                <BadHabit_WPFTools:ComboBox 
                            Grid.Column="1" Grid.Row="4"                             
                            DisplayMemberPath="UnitName"
                            IsTextSearchEnabled="True"
                            TextSearch.TextPath="UnitName"
                            MaxLength="50"
                            IsEditable="True"
                            Text="{Binding DefaultUnitName, UpdateSourceTrigger=LostFocus}"                                   
                            ItemsSource="{Binding Source={StaticResource GenericUnitList}}"
                            >
                    <BadHabit_WPFTools:ComboBox.Style>
                        <Style BasedOn="{StaticResource FormComboBox}" TargetType="BadHabit_WPFTools:ComboBox">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ClientContactRole}" Value="True">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </BadHabit_WPFTools:ComboBox.Style>
                </BadHabit_WPFTools:ComboBox>
                
                <Border x:Name="exchangeAlertBorder"
                        Style="{StaticResource AlertBorder}"
                        Grid.Row="5" Grid.ColumnSpan="2"
                        Visibility="Collapsed">
                <TextBlock Text="{x:Static props:Resources.Exchange_contact_alert}"/>    
                </Border>

                

            </Grid>

         
        </GroupBox>

    </StackPanel>
    
    
    
</UserControl>
